#include <iostream>
#include <unistd.h>

#include "bSysSubExample.h"
#include "sys/bSysComposit.h"
#include "yunbaapi/yunbaSysNode.h"

#include "daqsys/bDaqMod.h"
#include "daqsys/BaseDaq.h"
#include "uploadsys/uploadBase.h"

#include "serialmod/serialMod.h"
#include "daqtask/daqTask.h"
#include <thread>
using namespace std;

class uploadtask : public uploadBase{
public:
    uploadtask(string name) : uploadBase(name) {}

    virtual int initcfg() {
        cout << "uploadtask init" << endl;
        cout << addUploadDevice("testupload") << endl;
        return 0;
    }

    virtual int start(){

        connect();
        while (true){
            string data = "hello";
            cout << "will send data" <<endl;
            sendData((void *)data.c_str(),data.size());
            sleep(2);
        }
    }

    virtual int end(){}
};

int main() {
    auto * app = new bSysComposit;


//    app->Add(new yunbaMod("testupload")); //添加yunba模块
//    app->Add(new uploadtask("test2")); //测试yunba模块使用

#if 1
    //采集模块使用例程
    app->Add(new serialMod("testdaq")); //生成某个特定功能的采集模块
    app->Add(new Daqcfg("daqcfg"));	  //采集模块的配置 如设置波特率
    app->Add(new daqTask("test1")); //模拟采集进程 发送接受数据

#endif
    app->initcfg();

    app->start();

    app->wait();


    return 0;
}